<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>留言板</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <link rel="stylesheet" href="/layuiadmin/layui/css/layui.css" media="all">
  <link rel="stylesheet" href="/layuiadmin/style/admin.css" media="all">
  <link rel="stylesheet" href="/layuiadmin/style/template.css" media="all">
</head>
<body>


<div class="layui-fluid layadmin-message-fluid">
  <div class="layui-row">
    <div class="layui-col-md12">

      <form class="layui-form" action="/liuyan/liuyan" enctype="multipart/form-data" method="post">
        <div class="layui-form-item layui-form-text">
          <div class="layui-input-block">
            <textarea name="desc"  placeholder="既然来了，就留下点什么吧" class="layui-textarea"></textarea>
          </div>
        </div>
        <div class="layui-form-item" style="overflow: hidden;">
          <div class="layui-input-block layui-input-right">
            <button class="layui-btn" type="submit">发表</button>
          </div>
          <div class="layadmin-messag-icon">
              <input type="text" name="toName" value="${requestScope.toName}" style="display:none;">
              <input type="text" name="fromName" value="${requestScope.fromName}" style="display:none;">
              <input type="file" style="display: none" class="file" name="file"  onchange="change(this)">
            <a href="javascript:;"><i class="layui-icon layui-icon-face-smile-b"></i></a>
            <a href="javascript:;"><i class="layui-icon layui-icon-picture" onclick="upload()"></i></a>
          </div>
        </div>
          <div id="im" style="display: none">
              <img id="image" src="" style="width: 100px">
          </div>
      </form>

    </div>


    <div class="layui-col-md12 layadmin-homepage-list-imgtxt message-content">
        <c:forEach items="${requestScope.liuyan}" var="liuyan">
            <div class="media-body">
                <a href="javascript:;" class="media-left" style="float: left;">
                    <img src="${liuyan.fromImage}" height="46px" width="46px">
                </a>
                <div class="pad-btm">
                    <p class="fontColor"><a href="javascript:;">${liuyan.fromName}</a></p>
                    <p class="min-font">
              <span class="layui-breadcrumb" lay-separator="">
                <a href="javascript:;" class="layui-icon layui-icon-cellphone"></a>
                <a href="javascript:;">${liuyan.date}</a>
              </span>
                    </p>
                </div>
                <p class="message-text">${liuyan.content}</p>

                <div class="pad-btm">
                    <p class="min-font" style="margin: 20px 0px">
              <span class="layui-breadcrumb">
                <a class="layui-icon layui-icon-reply-fill" onclick="lypl('${liuyan.id}','${requestScope.fromName}','','')">评论</a>
                  <nbsp/><nbsp/><nbsp/><nbsp/><nbsp/>
                  <c:if test="${liuyan.toId==requestScope.toName || liuyan.fromId == requestScope.fromName}">
                <a class="layui-icon layui-icon-delete" href="/del/ly/${liuyan.id}/${requestScope.toName}/${requestScope.fromName}">删除</a>
                  </c:if>
              </span>
                    </p>
                </div>
                <c:forEach items="${requestScope.pl}" var="pl">
                    <c:if test="${pl.liuyanId==liuyan.id}">
                <div class="media-list">
                    <div class="media-item" style="margin-left: 30px">
                        <a href="javascript:;" class="media-item-left">
                            <img class="img-xs" src="${pl.fromImage}">
                        </a>
                        <div class="media-text">
                            <div>
                                <a href="javascript:;">${pl.fromName}</a>
                                <mdall> ${pl.date}</mdall>
                            </div>
                            <div>${pl.content}</div>
                        </div>

                        <div class="pad-btm">
                            <p class="min-font" style="margin: 20px 0px">
              <span class="layui-breadcrumb">
                <a class="layui-icon layui-icon-reply-fill" onclick="lypl('${liuyan.id}','${requestScope.fromName}','${pl.fromId}','@${pl.fromName}:')">评论</a>
                  <nbsp/><nbsp/><nbsp/><nbsp/><nbsp/>
                  <c:if test="${liuyan.toId==requestScope.toName || liuyan.fromId == requestScope.fromName}">
                      <a class="layui-icon layui-icon-delete" href="/del/pl/${pl.id}/${requestScope.toName}/${requestScope.fromName}">删除</a>
                  </c:if>
              </span>
                            </p>
                        </div>
                    </div>
                </div>
                    </c:if>
                </c:forEach>
                    <%--评论--%>
                <div class="layui-col-md12 ${liuyan.id}" style="display: none;">
                    <form class="layui-form" action="/liuyan/pinglun">
                        <input type="text" name="lyId" class="lyId" style="display: none">
                        <input type="text" name="fromName" class="fromName"  style="display: none">
                        <input type="text" name="toName" class="toName"  style="display: none">
                        <input type="text" name="rtname" style="display: none" value="${requestScope.toName}">
                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <input type="text" name="desc" id="desc" required  lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item" style="overflow: hidden;">
                            <div class="layui-input-block layui-input-right">
                                <button class="layui-btn" type="submit">发表</button>
                            </div>
                        </div>
                    </form>
                </div>

            </div>
        </c:forEach>

        <div style="padding-top: 30px;">
            <a href="/all/friends/${requestScope.fromName}"  class="layui-btn layui-btn-primary layui-btn-sm">返回主页</a>
        </div>
     </div>
    </div>
  </div>
</div>


  <script src="/layuiadmin/layui/layui.js"></script>
  <script>
      var $ ;
  layui.config({
    base: '/layuiadmin/'
  }).extend({
    index: 'lib/index'
  }).use(['index']);
  layui.use(['layer','form'],function(){
    var form = layui.form;
    $ = layui.jquery;
  })
  function upload(){
      $(".file").click();
  }

  function lypl(id,fName,tName,desc) {
      $("."+id).css('display','block');
      $(".lyId").val(id);
      $(".fromName").val(fName);
      $(".toName").val(tName);
      $('#desc').attr('placeholder',desc);
  }

      function change(val) {
            $('#im').css("display","block")
          $('#image').attr("src","/image/"+val.value.split("\\")[2].split("\.")[0]+"/"+val.value.split("\\")[2].split("\.")[1])
      }
  </script>
</body>
</html>